<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="${ctx}/css/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>
<script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
<!-- DATATABLES CSS END -->

<h1 class="page-title">${listTitle}</h1>

<div class="container_12 clearfix leading">
    <%@include file="/WEB-INF/pages/employee/staff_orgtab.jsp" %>
    <!--control layer -->
    <div class="tabs side grid_12 leading">
        <div class="clear"></div>
        <div class="grid_12">
            
            <div class="form-action clearfix">
                <s:if test="#request.operation=='select' || #request.operation=='staffselect'">
                    <p>
                        <a href="javascript:toUrl();" class="button"><span class="icon"
                                                                           style="background:url(${ctx}/images/img/add.png)">&nbsp;</span>确认选择</a>
                    </p>
                </s:if>
                <s:else>
                    <p id="p_opt">
                        <input type="checkbox" id="form-all" value="1" onchange="checkAll(this,'check_staff')"/><label for="form-all">全选</label>
                        <button class="button" type="button" onclick="deleteEmployees()">批量删除</button>
                        <a class="button" href="javascript:updateSelectedEmployees()"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>修改</a>
                        <a class="button" href="javascript:void(0);" onclick="addEmployee()"><span class="icon" style="background:url(${ctx}/images/img/add.png)">&nbsp;</span>添加</a>
                        <a class="button" href="javascript:void(0);" onclick="importEmployees()"> <span class="icon" style="background:url(${ctx}/images/img/table_go.png)">&nbsp;</span>导入</a>
                    </p>
                    <p id="p_display" style="display: none;">
                        <input type="checkbox" disabled="disabled"/><label for="form-all">全选</label>
                        <button class="button" type="button" disabled="disabled">批量删除</button>
                        <a class="button" href="javascript:void(0)"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>修改</a>
                        <a class="button" href="javascript:void(0);"><span class="icon" style="background:url(${ctx}/images/img/add.png)">&nbsp;</span>添加</a>
                        <a class="button" href="javascript:void(0);"><span class="icon" style="background:url(${ctx}/images/img/table_go.png)">&nbsp;</span>导入</a>
                    </p>
                </s:else>

            </div>

        </div>


    </div>
    <!--control layer end-->
</div>

<div class="clear"></div>

<script type="text/javascript">
    //add.wxn:员工基本数据导入
    function importEmployees(){
        if (confirm('请将员工基本数据文件重命名为"employee_data.xls"，并拷贝到tomcat/webapps/ehr目录下，确定要继续吗？')) {
            $("#p_opt").hide();
            $("#p_display").show();
            var url = "${ctx}/ajax/employee-import.xhtml"
            $.ajax(url, {
                type:"POST",
                dataType:"json",
                cache:false,
                success:function(message) {
                    $("#p_display").hide();
                    $("#p_opt").show();
                    if(message == "file_is_empty"){
                        alert("没有找到数据文件或数据文件为空");
                    }else if(message == "success"){
                        alert("数据导入成功");
                        location.reload(); //重新加载页面
                    }else if(message != null && message.length > 0){
                        alert(message);
                        location.reload(); //重新加载页面
                    }
                },
                complete:function() {
                }
            });
        }
    }
</script>
